package com.cavy.platform.server.dto;

import com.cavy.platform.server.validator.*;
import lombok.Data;

import javax.validation.GroupSequence;
import javax.validation.constraints.NotNull;

/**
 * @author 唐旭
 * @Date 2018/7/20
 */
@Data
@GroupSequence({FormatValidatorGroup.class, LastValidatorGroup.class, StageDeleteDto.class})
@PipelineExist(message = "流水线不存在", groups = LastValidatorGroup.class)
@ProjectExist(message = "项目不存在", groups = LastValidatorGroup.class)
@StageExist(message = "流水线步骤不存在", groups = LastValidatorGroup.class)
public class StageDeleteDto implements ProjectExistData, PipelineExistData, StageExistData {
    //pipeline信息
    @NotNull(message = "项目名称不能为空", groups = FormatValidatorGroup.class)
    private String projectName;
    @NotNull(message = "工作空间不能为空", groups = FormatValidatorGroup.class)
    @WorkspaceExist(groups = LastValidatorGroup.class)
    private String workspace;
    @NotNull(message = "流水线名称不能为空", groups = FormatValidatorGroup.class)
    private String pipeline;
    //步骤信息
    @NotNull(message = "步骤名称不能为空", groups = FormatValidatorGroup.class)
    private String name;

    @Override
    public String getPipelineName() {
        return pipeline;
    }

    @Override
    public String getPipelineFieldName() {
        return "pipeline";
    }

    @Override
    public String getProjectPropertyName() {
        return "projectName";
    }

    @Override
    public String getStageName() {
        return name;
    }

    @Override
    public String getStageFieldName() {
        return "name";
    }
}
